/*
 *  Classe che implementa il JPanel contenente titolo e pulsante di chiusura della
 *  delle tab che si aggiungono in Sybel di volta in volta
 */

package sybel.pan.util;

import javax.swing.border.BevelBorder;
import sybel.Sybel;

/**
 *
 * @author Stefano
 */
public class TabbedPaneTitle extends javax.swing.JPanel{
    private BevelBorder BevelBorder;
    private Sybel sybel;

    /** Creates new form TabbedPaneTitle */
    public TabbedPaneTitle(Sybel sib,String s) {
        initComponents();
        jLabel.setText(s);
        sybel = sib;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel = new javax.swing.JLabel();
        jButtClose = new javax.swing.JButton();

        jLabel.setText("jLabel1");

        jButtClose.setText("x");
        jButtClose.setBorder(null);
        jButtClose.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                jButtCloseMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                jButtCloseMouseExited(evt);
            }
        });
        jButtClose.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtCloseActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtClose, javax.swing.GroupLayout.DEFAULT_SIZE, 15, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel)
                .addComponent(jButtClose, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jButtCloseMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtCloseMouseEntered
        jButtClose.setBorder(BevelBorder);
    }//GEN-LAST:event_jButtCloseMouseEntered

    private void jButtCloseMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtCloseMouseExited
        jButtClose.setBorder(null);
    }//GEN-LAST:event_jButtCloseMouseExited

    private void jButtCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtCloseActionPerformed
        sybel.closeTab(this);
    }//GEN-LAST:event_jButtCloseActionPerformed

   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtClose;
    private javax.swing.JLabel jLabel;
    // End of variables declaration//GEN-END:variables

}
